--[[
	Atmosphere Addon
	by looter, foszor, deruu, waxx
--]]

atmos 				= {};
atmos.AllowedMaps 	= {};
atmos.StormData 	= {};
atmos.HorizonData 	= {};

-- CONFIG
atmos.Debug = false; -- attempt to work on all maps regardless of whitelist
atmos.ClientMode = true; -- force starting atmos without permission from the server
atmos.Version = 1.3; --now for gmod 13 wooo
atmos.ForceClientDL = true; -- only set to false if content is packed into the map
atmos.RemoveSuns = true; -- keep this true unless you want two suns like its fucking star wars or something you cunt
atmos.Dynamic = true; -- changes sky every so many seconds
atmos.CurrentSky = 1; -- default sky, change if you want i guess, should work fine
atmos.DynamicInterval = 8*60; -- amount in seconds to change the sky, default is 8 minutes
atmos.StormInterval = 30*60; -- amount in seconds to begin a storm, default every 30 minutes
atmos.StormDuration = 6*60; -- amount in seconds the storm will last, default is 6 minutes
atmos.EnableStorms = true; -- set to false if you never want it to rain

-- You add maps this works on here, if the map isnt allowed this doesnt load.
atmos.AllowedMaps["gm_construct"] = true;
atmos.AllowedMaps["gm_construct_13"] = true;
atmos.AllowedMaps["gm_buttes"] = true;
atmos.AllowedMaps["md_ironsky_a4"] = true;
atmos.AllowedMaps["md_ironsky_a5"] = true; -- just incase, for later revisions
atmos.AllowedMaps["md_ironsky_a6"] = true;
atmos.AllowedMaps["md_ironsky_a7"] = true;
atmos.AllowedMaps["md_ironsky_a8"] = true;

-- You have to configure the storm system for use with specific maps for render.DrawQuadEasy
atmos.StormData["gm_construct"] = { pos = 10240, w = 20480, h = 20480 }; -- not used, yet
atmos.StormData["gm_construct_13"] = { pos = 10240, w = 20480, h = 20480 }; -- not used, yet

-- At the moment only certain sized maps support rendering the Horizon correctly
atmos.HorizonData["gm_construct"] = true;
atmos.HorizonData["gm_construct_13"] = true;

-- DO NOT TOUCH
atmos.HooksLoaded = false; -- do not touch
atmos.Storming = false; -- do not touch
atmos.Inside = false; -- do not touch
atmos.NextChange = CurTime() + atmos.DynamicInterval; -- do not touch
atmos.NextStorm = CurTime() + atmos.StormInterval; -- do not touch

-- enums
SKY_DAWN						= 1;
SKY_DAY							= 2;
SKY_DUSK						= 3;
SKY_NIGHT						= 4;
SKY_BLOWOUT                     = 5; -- not used atm
SKY_STORM						= 6;
SKY_NUM_CLOUDS					= 8;

print("\n[atmos] v".. tostring( atmos.Version ) .." - init.");
	
if SERVER then
	
	util.AddNetworkString( "atmosRecvData" )
	util.AddNetworkString( "atmoschangesky" )
	util.AddNetworkString( "atmosStart" )
	util.AddNetworkString( "atmosrecvstorm" )
	
	AddCSLuaFile( "atmos_init.lua" )
	AddCSLuaFile( "atmos/atmos_shared.lua" );
	AddCSLuaFile( "atmos/Client/atmos_hooks.lua" );
	AddCSLuaFile( "atmos/Client/atmos_nature.lua" );
	
	include("atmos/atmos_shared.lua");
	include("atmos/Server/atmos_nature.lua")
	
	if( atmos.ForceClientDL ) then
	
		include("atmos/Server/atmos_resources.lua")
		
	end
	
	if( atmos.RemoveSuns ) then
		
		timer.Simple( 1, function()
		
			for k,v in pairs( ents.FindByClass('env_sun' ) ) do 

				v:Remove() 
				print("\n[atmos] removed a sun.");
					
			end
		
		end );
	
	end

end

if CLIENT then
	
	include("atmos/atmos_shared.lua");
	include("atmos/Client/atmos_hooks.lua")
	include("atmos/Client/atmos_nature.lua")
	
end

